function [max_col,min_col,mean_col,X] = average_scale(X_in)
    max_col = max(X_in);
    min_col = min(X_in);
    mean_col = mean(X_in, 1);
    % Check for division by zero (when max_col == min_col)
    divisor = max_col - min_col;
    divisor(divisor == 0) = 1;  % Replace zeros with ones to avoid division by zero
    
    X = (X_in - mean_col) ./ divisor;
end